/**
 * Copyright (c) 2011-2012 Tomi Paananen.
 *
 * Part of Quick Gestures engine library.
 */

#ifndef __QUICKGESTURESENGINE_H__
#define __QUICKGESTURESENGINE_H__

// Qt includes
#include <QObject>
#include <QPoint>

// qgengine includes
#include "gesture.h"
#include "qgenginepriv.h"

// Forward declaraions
class ClassifierThread;
class GestureModel;
class StorageThread;


class QGLIB_EXPORT QuickGesturesEngine : public QObject
{
    Q_OBJECT
    Q_ENUMS(EngineStates)
    Q_PROPERTY(int state READ state NOTIFY stateChanged)
    Q_PROPERTY(StorageThread* storageThread READ storageThread NOTIFY storageThreadChanged)
    Q_PROPERTY(GestureModel* model READ gestureModel NOTIFY modelChanged)

public: // Data types

    enum EngineStates {
        Idle = 0,
        Processing,
        Recognizing,
        Cancelling
    };

public: // Construction and destruction
    explicit QuickGesturesEngine(QObject *parent = 0);
    virtual ~QuickGesturesEngine();

public:
    ClassifierThread *classifierThread() const;

    // Property getters
    int state() const;
    StorageThread *storageThread() const;
    GestureModel *gestureModel() const;

public slots:
    bool recognize(Gesture *gesture);
    void cancelRecognition();
    void clearModel();

private slots:
    void setState(EngineStates state);
    void setStateToIdle();
    void cancellationConfirmed();

signals:
    void stateChanged(int state);
    void succeeded(quint32 id, const QString &name);
    void failed(int error);
    void cancelled();
    void progress(int percentsComplete);

    // Property signals
    void storageThreadChanged(StorageThread *storageManager);
    void modelChanged(GestureModel *model);

private: // Data
    ClassifierThread *m_classifierThread; // Owned
    StorageThread *m_storageThread; // Owned
    GestureModel *m_gestureModel; // Owned
    Gesture *m_tempGesture; // Owned
    EngineStates m_state;

    Q_DISABLE_COPY(QuickGesturesEngine)
};


#endif /* __QUICKGESTURESENGINE_H__ */

// End of file.
